package autohotkeyide;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author sad
 */
public class RegExpImageFinder {

    private Pattern innerPattern = Pattern.compile("\"([^\\\"]*?\\.img)\"", Pattern.DOTALL);
    private FindEvent event;

    public RegExpImageFinder(String pattern) {
        innerPattern = Pattern.compile(pattern);
    }

    public RegExpImageFinder() {
    }

    public void trySearch(String text) {
        Matcher matcher = innerPattern.matcher(text);
        while (matcher.find()) {
            if (event != null) {
                event.onFind(matcher);
            }
        }
    }

    public void setOnFindEvent(FindEvent event) {
        this.event = event;
    }

    public static interface FindEvent {

        void onFind(Matcher match);
    };
}
